Grouping data based on object properties